from odoo import models, fields


class EstateProperty(models.Model):
    _name = 'estate.property'
    _description = "房地产广告模块"

    name = fields.Char(string='Title', default="Unknown")
    description = fields.Text(string='description')
    postcode = fields.Char(string='Postcode')
    date_availability = fields.Date(string='Available From')  # 2021-11-06
    expected_price = fields.Float(string='Expected Price')
    selling_price = fields.Float(string='Selling Price')
    bedrooms = fields.Integer(string='Bedrooms')
    living_area = fields.Integer(string='Living Area')
    facades = fields.Integer(string='facades')
    garage = fields.Boolean(string='garage')
    garden = fields.Boolean(string='garden')
    garden_area = fields.Integer(string='garden_area')
    garden_orientation = fields.Selection([('North', '北'),
                                           ('South', '南'),
                                           ('East', '东'),
                                           ('West', '西')],
                                          string='garden_orientation')
    last_seen = fields.Datetime("Last Seen", default=lambda self: fields.Datetime.now())
    saleman = fields.Many2one('res.users', string='卖家')
    buyer = fields.Many2one('res.partner', string='买家')
    property_type_id = fields.Many2one('estate.property.type', string='房屋类型')
    tag_ids = fields.Many2many('estate.property.tag',
                               'estate_property_estate_property_tag_rel',
                               'property_id',
                               'tag_id',
                               string='标签')
    offer_ids = fields.One2many('estate.property.offer', 'property_id', string='优惠')
